
var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, o, n) {
    var c, r = arguments.length, i = r < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(e, t, o, n); else for (var a = e.length - 1; 0 <= a; a--) (c = e[a]) && (i = (r < 3 ? c(i) : 3 < r ? c(t, o, i) : c(t, o)) || i);
    return 3 < r && i && Object.defineProperty(t, o, i), i;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("AudioManager"), s = e("GameConfig"), c = e("WebManager"), l = cc._decorator, d = l.ccclass, u = l.property, p = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.viewname = "", e.animation = "", e.skeleton = null, e.isEffect = !1, e.type = 0, 
        e;
    }
    return i(e, t), e.prototype.onEnable = function() {
        this.startAccelerometer(), this.onAccelerometerChange();
    }, e.prototype.onDisable = function() {
        this.stopAccelerometer();
    }, e.prototype.startAccelerometer = function() {
        GA.PA && GA.PA.startAccelerometer && GA.PA.startAccelerometer({
            success: function() {},
            fail: function() {}
        });
    }, e.prototype.onAccelerometerChange = function() {
        var t, o, n = this;
        GA.PA && GA.PA.onAccelerometerChange && (o = t = 0, GA.PA.onAccelerometerChange(function(e) {
            !n.isEffect && (Math.abs(o - e.x) >= s.GC.accelerometerOffect || Math.abs(0 - e.y) >= s.GC.accelerometerOffect) && (n.pushEvent("触发摇动"), 
            ++t >= s.GC.accelerometerCount && (t = 0, n.isEffect = !0, n.stopAccelerometer(), 
            0 == n.type ? n.doEffect() : n.node.emit("effect"))), o = e.x;
        }));
    }, e.prototype.stopAccelerometer = function() {
        GA.PA && GA.PA.stopAccelerometer && GA.PA.stopAccelerometer({
            success: function() {},
            fail: function() {}
        });
    }, e.prototype.doEffect = function() {
        var e = this;
        this.pushEvent("摇动成功"), r.default.getInstance().playAudio("机甲出现音效");
        var t = this.skeleton;
        t.setPosition(cc.v2(1200, 0)), t.active = !0;
        var o = t.getComponent(sp.Skeleton);
        t.premultipliedAlpha=false;
        o && o.setAnimation(0, this.animation, !0), cc.tween(t).to(10, {
            position: cc.v3(-1200, 0)
        }).call(function() {
            e.isEffect = !1, t.setPosition(cc.v2(1200, 0)), t.active = !1, e.startAccelerometer(), 
            e.onAccelerometerChange();
        }).start();
    }, e.prototype.pushEvent = function(e) {
        c.default.getInstance().sentLog("点击" + this.viewname + "界面" + e + "按键");
    }, a([ u ], e.prototype, "viewname", void 0), a([ u ], e.prototype, "animation", void 0), 
    a([ u(cc.Node) ], e.prototype, "skeleton", void 0), a([ u ], e.prototype, "type", void 0), 
    a([ d ], e);
}(cc.Component);

n.default = p;